#include <iostream>
#include <vector>

class Shape {
public:
    virtual double area() = 0;
    virtual ~Shape() = default;
};

class Rectangle : public Shape
{
public:
    Rectangle(double length,double width) : width(width),length(length) { }
    double area()
    {
        return width * length;
    }
private:
    double width;   //自由复制加m
    double length;
};

class Circle : public Shape
{
public:
    Circle(double radius) : radius(radius) { }
    double area()
    {
        /*圆形面积*/
        return 3.14 * radius * radius;
    }
private:
    double radius;
};
template <typename Container>
double calculateTotalArea(Container& shapes)
{
    double totalArea = 0.0;
    for(auto ite = shapes.begin(); ite != shapes.end(); ite++)
    {
        totalArea += (*ite)->area();
    }
    return totalArea;
}
int main()
{
    std::vector<Shape*> shapes;
    shapes.push_back(new Rectangle(3, 4));
    shapes.push_back(new Circle(5));

    double totalArea = calculateTotalArea(shapes);
    std::cout << "Total area: " << totalArea << std::endl;
    return 0;
}